<template>
  <el-container>
    <el-header>
      <div class="logo"></div>
      Header
    </el-header>
    <el-container>
      <!-- <el-aside style="width: 64px;"> -->
      <el-aside :style="spread">
        <!-- <el-radio-group v-model="isCollapse" style="margin-bottom: 0px;" @change="spreadChange">
          <el-radio-button :label="false">展开</el-radio-button>
          <el-radio-button :label="true">收起</el-radio-button>
        </el-radio-group> -->
        <el-button v-if="!isCollapse" type="primary" icon="el-icon-caret-left" @click="spreadChange" style="width:100%;"></el-button>
        <el-button v-else type="primary" icon="el-icon-caret-right" @click="spreadChange" style="width:100%;"></el-button>
        <el-menu default-active="2-1" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" :collapse="isCollapse">
          <el-menu-item index="1">
            <i class="el-icon-location"></i>
            <span slot="title"><router-link to="/">仪表盘</router-link></span>
          </el-menu-item>
          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span slot="title">数据维护</span>
            </template>

            <el-menu-item-group>
              <!-- <span slot="title">分组一</span> -->
              <el-menu-item index="2-1">用户管理</el-menu-item>
              <el-menu-item index="2-2">课程管理</el-menu-item>
              <el-menu-item index="2-3">分类管理</el-menu-item>
            </el-menu-item-group>
            <!-- <el-menu-item-group title="分组2">
              <el-menu-item index="2-3">选项3</el-menu-item>
            </el-menu-item-group>
            <el-submenu index="2-4">
              <span slot="title">选项4</span>
              <el-menu-item index="2-4-1">选项1</el-menu-item>
            </el-submenu> -->
          </el-submenu>
          <!-- <el-menu-item index="3" disabled> -->
          <el-menu-item index="3">
            <i class="el-icon-document"></i>
            <span slot="title">基础设置</span>
          </el-menu-item>
          <el-menu-item index="4">
            <i class="el-icon-setting"></i>
            <span slot="title">系统管理</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-container>
        <el-main>
          Main
          <div class="main">
          </div>
        </el-main>
        <!--<el-footer>Footer</el-footer>-->
      </el-container>
    </el-container>
  </el-container>
</template>

<script>
  export default {
    data() {
      return {
        isCollapse: false,
        spread: {
          width: '300px',
        }
      };
    },
    methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },
      spreadChange: function () {
        if (this.isCollapse == true) {
          this.spread.width = '300px'
          this.isCollapse = false
        } else {
          this.spread.width = '64px'
          this.isCollapse = true
        }
      }
    }
  }
</script>

<style scoped>
  /**
   * =================== 菜单栏 =======================
   */
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 100%;
    min-height: 400px;
  }
  /**
   * ==================================================
   */
  
  .logo {
    width: 260px;
    height: 40px;
    background-color: black;
    /*margin: auto 0;*/
    margin-top: 10px;
  }
  
  .el-container,
  .main {
    height: 100%;
  }
  
  .el-header,
  .el-footer {
    background-color: #B3C0D1;
    color: #333;
    text-align: center;
    line-height: 60px;
  }
  
  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    /* line-height: 200px; */
  }
  
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    line-height: 160px;
  }
  
  body > .el-container {
    margin-bottom: 40px;
  }
  
  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }
  
  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
</style>